package com.heartunderblade.rpc.ErrorCode;

public class RpcException extends RuntimeException{
    private final String code;

    public String getCode() {
        return code;
    }

    @Override
    public String toString() {
        return "RpcException{" +
                "code='" + code + '\'' +
                ", message='" + getMessage() + '\'' +
                '}';
    }

    public RpcException(ErrorCode errorCode) {
        super(errorCode.getErrorMessage());
        this.code = errorCode.getCode();
    }
    public RpcException(ErrorCode errorCode, String detailMessage) {
        super(errorCode.getErrorMessage() + ": " + detailMessage);
        this.code = errorCode.getCode();
    }
}
